home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1995 January
/
1995-01b.d64
/
value of money
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
6KB
|
208 lines
5 rem copyright 1995 - compute publications intl ltd - all rights reserved
10 dc=1
20 space$=""
30 cur=1
40 d$="discrete "
50 c$="continuous"
60 printchr$(147)
70 rem the value of money
80 poke 53280,0:poke53281,0
90 print"[176][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][174]":n=1:gosub 100:goto 130
100 fori=1ton
110 print"[194]";space$;"[194]"
120 next i :return
130 print"[171][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][179]"
140 n=16:gosub 100
150 print"[171][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][179]"
160 n=1:gosub 100
170 print"[173][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][195][189]":print"[145][145][159]c[146]ompounding: ";
180 rem
190 print"";
200 if dc=1 thenprint"";d$
210 if dc=0 thenprint"";c$
220 print"[159]the value of money"
230 ifcur=1thenprint" *compound amount *":goto250
240 print" compound amount"
250 print" present worth"
260 print" sinking fund factor"
270 print" series compound amount"
280 print" capital recovery"
290 print" [160] series present worth"
300 print" arithmetic gradient"
310 print"q[146]uith[146]elpspace[146]"
320 a=0:g=0:p=0:f=0:rem these are reset-if nothing is entered,goes back to menu
330 geta$:ifa$<>"" anda$<>"[145]"anda$<>"h"anda$<>"q"anda$<>" "anda$<>"c"then 330
340 ifa$="c" ora$="q"ora$=" " then gosub 570
350 ifa$="c"anddc=1thendc=0:goto180
360 ifa$="c" anddc=0thendc=1:goto180
370 if a$="h" then gosub 1930
380 if a$="q" then end
390 if a$="[145]" and cur>1 then cur=cur-1:gosub430:gosub480:goto180
400 ifa$=" "then gosub 590:goto 180
410 ifa$=""and cur<7then cur=cur+1:gosub430:gosub480:goto180
420 goto 330
430 rem clear asterisks
440 print" "
450 fort=1to6:print" "
460 next t
470 return
480 rem put asterisks up
490 if cur<>1 then print"":goto 510
500 print"**"
510 fort=2to7
520 if t=curthen print"**":goto 540
530 print" "
540 next t
550 rem bell routine
560 return
570 poke54296,21:poke54277,9:poke54278,0:poke54273,48:poke54276,32:poke54276,33
580 return
590 rem calculation routine
600 printchr$(147)
610 if cur=1thengoto680
620 if cur=2thengoto840
630 if cur=3thengoto1000
640 if cur=4thengoto1160
650 if cur=5thengoto1360
660 if cur=6thengoto1520
670 if cur=7thengoto1720
680 rem
690 print"compound amount: ";
700 ifdc=1then printd$;""
710 ifdc<>1thenprintc$;""
720 input"present amount ($): ";p:print
730 ifp=0then goto20
740 input"interest rate per period (%): ";pr:print
750 input"time period: ";per
760 if dc=1 then f=p*((1+pr/100)^per)
770 ifdc<>1 thenr=(pr/100)
780 ifdc<>1 then f=p*(exp(r*per)*exp(r)-1)/(r*exp(r))
790 print"the future worth[160](compound amount) is"
800 print "$";f
810 print"press any key to continue"
820 geta$:ifa$=""then820
830 goto20
840 rem
850 print"present worth: ";
860 ifdc=1then printd$;""
870 ifdc<>1thenprintc$;""
880 input"future amount ($): ";f:print
890 if f=0then goto20
900 input"interest rate per period (%): ";pr:print
910 input"time period: ";per
920 if dc=1 then p=f/((1+pr/100)^per)
930 ifdc<>1 thenr=(pr/100)
940 ifdc<>1 then p=f*(exp(r)-1)/(r*exp(r*per))
950 print"the present worth[160]is"
960 print "$";p
970 print"press any key to continue"
980 geta$:ifa$=""then980
990 goto20
1000 rem
1010 print"sinking fund: ";
1020 ifdc=1then printd$;""
1030 ifdc<>1thenprintc$;""
1040 input"future amount ($): ";f:print
1050 iff=0thengoto20
1060 input"interest rate per period (%): ";pr:print
1070 input"time period: ";per
1080 if dc=1 then a=(f*(pr)/100)/(((1+pr/100)^per)-1)
1090 ifdc<>1 thenr=(pr/100)
1100 ifdc<>1 then a=(f*(pr)/100)/(exp(r*per)-1)
1110 print"the payments per period are"
1120 print "$";a
1130 print"press any key to continue"
1140 geta$:ifa$=""then1140
1150 goto20
1160 rem
1170 print"series compound: ";
1180 ifdc=1then printd$;""
1190 ifdc<>1thenprintc$;""
1200 input"annuity amount ($): ";a:print
1210 ifa=0thengoto20
1220 input"interest rate per period (%): ";pr:print
1230 input"time period: ";per
1240 if pr<> 0 then 1280
1250 print"can't compute: division by zero"
1260 print"press any key to continue"
1270 geta$:ifa$=""then1270
1280 if dc=1 then f=a*((1+pr/100)^per-1)/(pr/100)
1290 ifdc<>1 then r=(pr/100)
1300 ifdc<>1 then f=a*(exp(r*per)-1)/r
1310 print"the future amount is"
1320 print "$";f
1330 print"press any key to continue"
1340 geta$:ifa$=""then1340
1350 goto20
1360 rem
1370 print"capital recovery: ";
1380 ifdc=1then printd$;""
1390 ifdc<>1thenprintc$;""
1400 input"present amount ($): ";p:print
1410 ifp=0thengoto20
1420 input"interest rate per period (%): ";pr:print
1430 input"time period: ";per
1440 if dc=1 then a=p*((pr/100)*(1+pr/100)^per)/((1+pr/100)^per-1)
1450 ifdc<>1 then r=(pr/100)
1460 ifdc<>1 then a=p*r*exp(r*per)/(exp(r*per)-1)
1470 print"the annuity amount is"
1480 print "$";a
1490 print"press any key to continue"
1500 geta$:ifa$=""then1500
1510 goto20
1520 rem
1530 print"series present worth: ";
1540 ifdc=1then printd$;""
1550 ifdc<>1thenprintc$;""
1560 input"annuity amount ($): ";a:print
1570 ifa=0thengoto20
1580 input"interest rate per period (%): ";pr:print
1590 input"time period: ";per
1600 if pr<> 0 then 1640
1610 print"can't compute: division by zero"
1620 print"press any key to continue"
1630 geta$:ifa$=""then1630
1640 if dc=1 then p=a*((1+pr/100)^per-1)/(pr/100*(1+pr/100)^per)
1650 ifdc<>1 then r=(pr/100)
1660 ifdc<>1 then p=a*(exp(r*per)-1)/(r*exp(r*per))
1670 print"the present worth is"
1680 print "$";p
1690 print"press any key to continue"
1700 geta$:ifa$=""then1700
1710 goto20
1720 rem
1730 ifdc=1then1790
1740 print"arithemtic gradient can't be calculated by this program ";
1750 print"for a continuous compounding period."
1760 print"press any key to continue"
1770 geta$:ifa$=""then1770
1780 run
1790 print"arithmetic gradient: ";
1800 ifdc=1then printd$;""
1810 input"uniform increase ($): ";g:print
1820 ifg=0thengoto20
1830 input"interest rate per period (%): ";pr:print
1840 input"time period: ";per
1850 first=1/(pr/100)
1860 sec=per/((1+pr/100)^per-1)
1870 a=g*(first-sec)
1880 print"the annuity amount is"
1890 print "$";a
1900 print"press any key to continue"
1910 geta$:ifa$=""then1910
1920 goto20
1930 rem help routine
1940 printchr$(147)
1950 print"[159]";
1960 print" *** help ***"
1970 print:print
1980 print"use the cursor up and down keys to"
1990 print"highlight an item, and then press"
2000 print"space to select it."
2010 print:print"press q to quit, h for this help screen"
2020 print"or c to toggle the compounding"
2030 print"method."
2040 print:print:print:print:print"press any key to continue"
2050 geta$:ifa$=""then 2050
2060 goto20:return